// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env:'a-1gb4haz213d919e3'
})

// 云函数入口函数
exports.main = async (event, context) => {
    const wxContext = cloud.getWXContext()
    const db=cloud.database()
    const studentCollention=db.collection('student')
    let openid=wxContext.OPENID
    let res=await studentCollention.where({
        openid
    }).get()
    console.log('res',res)
    if(res.data.length>0){
        result=res.data[0]
    }else{
        result={
            name:'nobody'
        }
    }

    return {
        result
    }
}